package converter

class DependencyRender {

	DependencyWalker dw = new DependencyWalker()

	String renderDependencies(File effectivePom) {
		Map map = dw.walkEffectivePom(effectivePom)
		StringBuilder sb = new StringBuilder("dependencies {\n")
		map.each{ key, value ->
			if(value) {
				sb.append(renderScopeValues(key, value))
			}
		}
		return sb.append("}\n")
	}

	String renderScopeValues(DependencyScope key, def values) {
		StringBuffer sb = new StringBuffer()
		SingleDependencyRender dr = new SingleDependencyRender()
		String scopeRender = key.render()
		values.each{
			sb.append("\t"+scopeRender+ " \"" +dr.contructSignature(it) + "\"\n")
		}
		return sb.toString()
	}

}
